package com.xiaoyuanxing.demo.mapper;

import com.xiaoyuanxing.demo.entity.AccountInfo;
import org.apache.ibatis.annotations.*;

/*
 **@author LuoShengYing
 **@date 2021/5/22
 */
@Mapper
public interface AccountInfoMapper {

    // 通过accountID，查询对应的AccountInfo数据
    @Select("select * from `accountinfo` where `accountID` = #{accountID}")
    AccountInfo selectByAccountID(@Param("accountID") long accountID);

    // 新增AccountInfo数据
    @Insert("insert `accountinfo`" +
            "set `accountID` = #{accountID}, `avatarUrl` = #{avatarUrl},`nickname` = #{nickname}, `sex` = #{sex}, `studentID` = #{studentID}, `trueName` = #{trueName}, `schoolID` = #{schoolID}, `collegeName` = #{collegeName}")
    boolean insertAccountInfo(AccountInfo accountInfo);

    // 更新AccountInfo数据
    @Update("update `accountinfo`" +
            "set `nickname` = #{nickname},`avatarUrl` = #{avatarUrl}, `sex` = #{sex}, `studentID` = #{studentID}, `trueName` = #{trueName}, `schoolID` = #{schoolID}, `collegeName` = #{collegeName}" +
            "where `accountID` = #{accountID}")
    boolean updateAccountInfo(AccountInfo accountInfo);

    // 删除AccountInfo数据
    @Delete("delete from `accountinfo` where `accountID` = #{accountID}")
    boolean deleteByAccountID(@Param("accountID") long accountID);
}
